import {http} from "@/utils/http";
import {BaseResponse} from "@/model/BaseResponse";
import {InterfaceInfoQueryRequest, InterfaceInfo, InterfaceInfoInvokeRequest} from "@/model/interfaceInfo";
import {Page} from "@/model/comon";



/** 分页查询获取全部接口*/
export const GetInterfaceInfoList = async (interfaceInfoQueryRequest: InterfaceInfoQueryRequest) => {
  return await http.post<InterfaceInfoQueryRequest, BaseResponse<Page<InterfaceInfo>>>(
    "/interfaceInfo/list/page/vo",
    {data: interfaceInfoQueryRequest}
  );
};

/** 测试接口*/
export const interfaceInfoInvoke = async (interfaceInfoInvokeRequest: InterfaceInfoInvokeRequest) => {
  return await http.post<object, BaseResponse<string>>("/interfaceInfo/invoke", {
    data: interfaceInfoInvokeRequest
  });
};

// admin start

/** 根据id删除接口*/
export const DeleteById = async (id: number) => {
  return await http.post<object, BaseResponse<boolean>>("/interfaceInfo/delete", {
    data: {id}
  });
};

/** 修改接口信息*/
export const UpdateInterfaceInfo = async (data: InterfaceInfo) => {
  return await http.post<InterfaceInfo, BaseResponse<boolean>>("/interfaceInfo/update", {
    data
  });
};

/** 新增接口信息 */
export const AddInterfaceInfo = async (interfaceInfo: InterfaceInfo) => {
  return await http.post<InterfaceInfo, BaseResponse<number>>("/interfaceInfo/add", {
    data: interfaceInfo
  });
};

/** 上线接口*/
export const OnlineInterfaceInfo = async (id: number) => {
  return await http.post<object, BaseResponse<boolean>>("/interfaceInfo/online", {
    data: {id}
  });
};

/** 下线接口*/
export const OfflineInterfaceInfo = async (id: number) => {
  return await http.post<object, BaseResponse<boolean>>("/interfaceInfo/offline", {
    data: {id}
  });
}

/** 接口分析*/
export const getInterfaceInfoAnalysis = async () => {
  return await http.post<object, BaseResponse<object>>("/analysis/top/interface/invoke");
};
// admin end
